a11y: Add _gtk_cell_accessible_parent_get_child_index()
authorBenjamin Otte <otte@redhat.com>
Thu, 10 Nov 2011 21:07:19 +0000 (22:07 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 16 Nov 2011 03:31:06 +0000 (04:31 +0100)
This will soon replace the shenanigans we do to keep the index of cells
current.

gtk/a11y/gtkcellaccessible.c
gtk/a11y/gtkcellaccessibleparent.c
gtk/a11y/gtkcellaccessibleparent.h

index 93f0ebe7715e98c1dc8e47518c2307dce537975f..54bd1adf4720c6e5dcfa1a0cf8cb28d48712aa9f 100644 (file)
@@ -91,8 +91,18 @@ static gint
 gtk_cell_accessible_get_index_in_parent (AtkObject *obj)
 {
   GtkCellAccessible *cell;
+  AtkObject *parent;
+  int index;
 
   cell = GTK_CELL_ACCESSIBLE (obj);
+  parent = gtk_widget_get_accessible (cell->widget);
+  if (parent == NULL)
+    return -1;
+
+  index = _gtk_cell_accessible_parent_get_child_index (GTK_CELL_ACCESSIBLE_PARENT (parent), cell);
+  if (index >= 0)
+    return index;
+
   if (atk_state_set_contains_state (cell->state_set, ATK_STATE_STALE) &&
       cell->refresh_index != NULL)
     {
index b63e5af57fd4ff706ad8bb646515f0c181ba524b..a05aaa1340209119e4efc5236ec9045e969e435e 100644 (file)
@@ -95,3 +95,19 @@ _gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent *parent,
   else
     return FALSE;
 }
+
+int
+_gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
+                                             GtkCellAccessible       *cell)
+{
+  GtkCellAccessibleParentIface *iface;
+
+  g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), FALSE);
+
+  iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
+
+  if (iface->get_child_index)
+    return (iface->get_child_index) (parent, cell);
+  else
+    return -1;
+}
index 7969a8b7fbce9b8ad8b21fb4b52f60e3f00132ad..f4e1ea28b85cf0e7aecb9cf2152dce7d8ad4e0b6 100644 (file)
@@ -58,6 +58,8 @@ struct _GtkCellAccessibleParentIface
                                  GdkRectangle            *cell_rect);
   gboolean ( *grab_focus)       (GtkCellAccessibleParent *parent,
                                  GtkCellAccessible       *cell);
+  int      ( *get_child_index)  (GtkCellAccessibleParent *parent,
+                                 GtkCellAccessible       *cell);
 };
 
 GType    _gtk_cell_accessible_parent_get_type         (void);
@@ -74,6 +76,8 @@ void     _gtk_cell_accessible_parent_get_cell_area    (GtkCellAccessibleParent *
                                                        GdkRectangle            *cell_rect);
 gboolean _gtk_cell_accessible_parent_grab_focus       (GtkCellAccessibleParent *parent,
                                                        GtkCellAccessible       *cell);
+int      _gtk_cell_accessible_parent_get_child_index  (GtkCellAccessibleParent *parent,
+                                                       GtkCellAccessible       *cell);
 
 G_END_DECLS